<template>
  <div>
    <!-- 阿里云视频播放器样式 -->
    <link
      rel="stylesheet"
      href="https://g.alicdn.com/de/prismplayer/2.8.1/skins/default/aliplayer-min.css"
    />
    <!-- 阿里云视频播放器脚本 -->
    <script
      charset="utf-8"
      type="text/javascript"
      src="https://g.alicdn.com/de/prismplayer/2.8.1/aliplayer-min.js"
    />
    <!-- <link
      rel="stylesheet"
      href="//g.alicdn.com/de/prismplayer/2.6.0/skins/default/aliplayer-min.css"
    /> -->
    <!-- <script
      type="text/javascript"
      src="//g.alicdn.com/de/prismplayer/2.6.0/aliplayer-min.js"
    ></script> -->
    <!-- 定义播放器dom -->
    <div id="J_prismPlayer" class="prism-player" />
  </div>
</template>
<script>
import video from "@/api/video";

export default {
  layout: "video", //应用video布局
  asyncData({ params, error }) {
    return video.getPlayAuth(params.vod).then((res) => {
        return{
            playAuth: res.data.data.playAuth,
            videoId: params.vod
        }
    });
  },
  /**
   * 页面渲染完成时：此时js脚本已加载，Aliplayer已定义，可以使用
   * 如果在created生命周期函数中使用，Aliplayer is not defined错误
   */
  mounted() {
    new Aliplayer(
      {
        id: "J_prismPlayer",
        vid: this.videoId, // 视频id
        playauth: this.playAuth, // 播放凭证
        encryptType: "1", // 如果播放加密视频，则需设置encryptType=1，非加密视频无需设置此项
        width: "100%",
        height: "500px",
        // useFlashPrism: true
      }
    );
    console.log("+++++++++++++++"+this.vid);
    console.log("playAuth-->" + this.playAuth)
    console.log("videoId-->"+this.videoId)

  },
};
</script>